﻿using System.Text;

namespace zevenseas.Community.Search
{
    public class WherePropertyContains : WhereProperty
    {
        private bool wildcardSearch = false;
        private string searchTerm;

        public string SearchTerm
        {
            get { return searchTerm; }
            set { searchTerm = value; }
        }

        public bool WildcardSearch
        {
            get { return wildcardSearch; }
            set { wildcardSearch = value; }
        }

        public override string ToString()
        {
            StringBuilder containsString = new StringBuilder();

            containsString.Append(@"CONTAINS (");
            containsString.Append(Property);
            containsString.Append(@",'""");
            containsString.Append(searchTerm);
            if (wildcardSearch) containsString.Append("*");
            containsString.Append(@"""')");

            return containsString.ToString();
        }
    }
}